

' -------------------------------------------
' Hands-On 10-1
' -------------------------------------------

Sub ChangeCode()
    Workbooks.Open Filename:="C:\Ex07_ByExample\Codes.xlsx"
    Windows("Practice_Excel10.xlsm").Activate
    Columns("D:D").Insert Shift:=xlToRight
    Range("D1").Formula = "Code"
    Columns("D:D").SpecialCells(xlBlanks).Select
    ActiveCell.FormulaR1C1 = "=VLookup(RC[1],Codes.xlsx!R1C1:R6C2,2)"
    Selection.FillDown
        With Columns("D:D")
            .EntireColumn.AutoFit
            .Select
        End With
    Selection.Copy
    Selection.PasteSpecial Paste:=xlValues
    Rows("1:1").Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .Orientation = xlHorizontal
        End With
    Workbooks("Codes.xlsx").Close
End Sub


' -------------------------------------------
' Hands-On 10-2
' -------------------------------------------

Sub WhatDate()
    Dim curDate As Date
    Dim newDate As Date
    Dim x As Integer
    
    curDate = Date
    For x = 1 To 365
        newDate = Date + x
    Next
End Sub


' -------------------------------------------
' Hands-On 10-3
' No code in this Hands-On.
' Please follow the instructions in the book.
' -------------------------------------------


' -------------------------------------------
' Hands-On 10-4
' No code in this Hands-On.
' Please follow the instructions in the book.
' -------------------------------------------


' -------------------------------------------
' Hands-On 10-5
' No code in this Hands-On.
' Please follow the instructions in the book.
' -------------------------------------------


' -------------------------------------------
' Hands-On 10-6
' -------------------------------------------

Sub MyProcedure()
    Dim strName As String
    Workbooks.Add
    strName = ActiveWorkbook.Name
    ' choose the Step Over to avoid stepping through the
    ' lines of code in the called procedure - SpecialMsg
    SpecialMsg strName
    Workbooks(strName).Close
End Sub


Sub SpecialMsg(n As String)
    If n = "Book2" Then
        MsgBox "You must change the name."
    End If
End Sub






